package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.PayReqInfo;
import com.party.course.service.IPayReqInfoService;
import com.party.common.core.page.TableDataInfo;

/**
 * 三方支付请求信息Controller
 *
 * @author ruoyi
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/course/payReq" )
public class PayReqInfoController extends BaseController {
    @Autowired
    private IPayReqInfoService payReqInfoService;

/**
 * 查询三方支付请求信息列表
 */
//@RequiresPermissions("course:payReq:list")
@GetMapping("/list" )
    public TableDataInfo list(PayReqInfo payReqInfo) {
        startPage();
        List<PayReqInfo> list = payReqInfoService.findList(payReqInfo);
        return getDataTable(list);
    }

    /**
     * 导出三方支付请求信息列表
     */
    //@RequiresPermissions("course:payReq:export")
    @Log(title = "三方支付请求信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, PayReqInfo payReqInfo) {
        List<PayReqInfo> list = payReqInfoService.findList(payReqInfo);
        ExcelUtil<PayReqInfo> util = new ExcelUtil<PayReqInfo>(PayReqInfo. class);
        util.exportExcel(response, list, "三方支付请求信息数据" );
    }

    /**
     * 获取三方支付请求信息详细信息
     */
    //@RequiresPermissions("course:payReq:query")
    @GetMapping(value = "/view/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(payReqInfoService.view(id));
    }

    /**
     * 新增三方支付请求信息
     */
    //@RequiresPermissions("course:payReq:add")
    @Log(title = "三方支付请求信息" , businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PayReqInfo payReqInfo) {
        return toAjax(payReqInfoService.add(payReqInfo));
    }

    /**
     * 修改三方支付请求信息
     */
    //@RequiresPermissions("course:payReq:edit")
    @Log(title = "三方支付请求信息" , businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody PayReqInfo payReqInfo) {
        return toAjax(payReqInfoService.updateEntity(payReqInfo));
    }

    /**
     * 删除三方支付请求信息
     */
    //@RequiresPermissions("course:payReq:remove")
    @Log(title = "三方支付请求信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(payReqInfoService.deleteIds(Arrays.asList(ids)));
    }
}
